<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>02-回调形式的ref</title>
  </head>
  <body>
    <div id="app"></div>

    <!-- 导入 react 主库 -->
    <script src="../js/react.development.js"></script>
    <!-- 导入 reactDom 扩展库 -->
    <script src="../js/react-dom.development.js"></script>
    <!-- 导入 babel 用于将jsx转为js -->
    <script src="../js/babel.min.js"></script>
    <!-- 导入 prop-types 用于对组件标签属性进行限制 -->
    <script src="../js//prop-types.js"></script>

    <script type="text/babel">
      // 定义类组件
      class Demo extends React.Component {

        // 点击提示右侧输入框内容
        showData = () => {
            const { input1 } = this
            alert(input1.value)
        }

         // 失去焦点提示右侧侧输入框内容
         showData1 = () => {
            const { input2 } = this
            alert(input2.value)
        }


        render() {
          return (
            <div>
              <input ref={(ele) => this.input1 = ele} type="text" />
              <button onClick={this.showData}>点击提示右侧内容</button>
              <input ref={(ele) => this.input2 = ele} onBlur={this.showData1} type="text" />
            </div>
          );
        }
      }
      ReactDOM.render(<Demo/>, document.getElementById('app'))
    </script>
  </body>
</html>
